#ifndef SlamWebSocket_H
#define SlamWebSocket_H

#include <QObject>
#include <QVariantMap>
#include "RobotCmdNode.hpp"

class QNetworkReply;
class QNetworkAccessManager;
class QTimer;
class QSharedMemory;

class SlamWebSocket : public QObject
{
    Q_OBJECT
public:
    explicit SlamWebSocket(int argc, char** argv, QObject *parent = nullptr);
    ~SlamWebSocket();


    void callStartLaser(const QString& serial);
    void callStopLaser();
    void callGetCloud();

signals:
    void sigReply(const QString& msg);

    // void sigPlatformStateReady(const QVariantMap& platformState);

protected:

public slots:
    void startLaser(const QString& serial);
    void stopLaser();
    void getCloud();
    void getRobotPos();
//    void resetLaser();
    //change0425

    void testData(const QString& serial);

private slots:
    void onReplyFinished(QNetworkReply* reply);
    void onTimerStartLaser();

    void onGetPlatformState();

private:
    void rosSpinThread();


private:
    QNetworkAccessManager* m_netAccesser;

    QTimer* m_timerStartLaser;
    QString m_strCurAction;
    QString m_strSerial;
    qint64  m_nCldSize;
    QString m_strCldMd5;

    // timer to get platformState
    QTimer* m_timerGetPlatformState;

    QSharedMemory* m_smSLAM;

    bool m_bIsBusy;

    int argc_;
    char** argv_;
    std::shared_ptr<RobotCmdNode> m_robotCmdNode;
    std::thread m_ros_spin_thread;
};

#endif // SlamWebSocket_H
